<?php
require_once('../../conf/config.php.inc');
require_once(SYBMAS_LIB_PATH.'/liblogin.php.inc');
require_once(SYBMAS_LAYOUT_PATH.'/layout.php.inc');
require_once(SYBMAS_LIB_PATH.'/libsybase.php.inc');
require_once(SYBMAS_LIB_PATH.'/libsybmas.php.inc');
require_once(SYBMAS_LAYOUT_PATH.'/menu.php.inc');
require_once('libtablas.php.inc');
verificar_inicio_sesion();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css"
	href="<?php echo LAYOUT_URI?>/sybmasstyle.css">
<script src="<?php echo LAYOUT_URI?>/jquery-1.2.1.min.js"
	type="text/javascript"></script>
<script src="<?php echo LAYOUT_URI?>/menu-collapsed.js"
	type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
	href="<?php echo LAYOUT_URI?>/style.css" />
<link rel="stylesheet" type="text/css"
	href="<?php echo JAVASCRIPT_URI?>/tabs/tabs.css">
<script src="<?php echo JAVASCRIPT_URI?>/tabs/tabs.js"
	type="text/javascript"></script>
<title>.:: Sybmas - Alta de Usuarios</title>
<!--[if lt IE 8]>
   <style type="text/css">
   li a {display:inline-block;}
   li a {display:block;}
   </style>
   <![endif]-->   
   
<script LANGUAGE="JavaScript">
<!-- Begin

agree = 0;  // 0 means 'no', 1 means 'yes'

//  End -->
</script>   
   
</head>
<body>
<script src="<?php echo JAVASCRIPT_URI?>/tooltip/wz_tooltip.js"
	type="text/javascript"></script>
<center>
<div id="container">
<div id="header"><?php generar_header();?></div>
<div id="scene">
<div id="modulos">
<ul id="menu" style="width: 150px;">
<?php echo generar_menu();?>
</ul>
</div>

<div id="title">Alta de Usuarios</div>
<div id="main">
<form name="enableform" method="POST" action="libaltausuario.php">
<?php
$dbname=$_SESSION['sybmas.user.dbname'];
foreach($_GET as $key => $value){
	$$key=$value;
	echo "<input type='hidden' name='$key' value='$value'>";
}

$cambio_bd_exitoso=true;
$sybuser_connection=start_default_sybuser_connection();
if($dbname){
	$cambio_bd_exitoso=sybase_select_db($dbname,$sybuser_connection);
}

if($cambio_bd_exitoso){
	$query="SELECT suid,uid,gid,name FROM sysusers";
	$result=sybase_query($query,$sybuser_connection);
	?>          
<h2>Creando usuario en base de datos:<?php echo $dbname?></h2>                         	
<table>
    <tr>
		<td>
			<span onmouseover="Tip('Usuario a Crear')" onmouseout="UnTip()">Selecciona el Nombre de Usuario a Crear: </span>
		</td>
		<td>
		   <?php 
		   	$sybmas_connection=start_sybmas_connection();             
           	$query="SELECT name FROM master..syslogins WHERE suid NOT IN ( ".
           			"SELECT suid FROM sysusers) ";   
			//echo $query;      
            $resultado=sybase_query($query,$sybuser_connection);
            echo "<select name='login'>";                        
            while ($fila=sybase_fetch_row($resultado)){                             
            	echo"<option value='$fila[0]'>$fila[0]";
            }                               
            echo "</select>";     
            ?>
        </td>             		                   
    </tr>	      	  		 
    <tr>
		<td><span onmouseover="Tip('Crear usuario con otro nombre')" onmouseout="UnTip()">Crear Usuario con diferente nombre al del Login:</span></td>	   					 			
		<td>			    			    			    				
			<input type="checkbox" name="enable" onClick="user=document.getElementById('user');user.disabled=!this.checked">&nbsp;
			<input type="text" name="user" id="user" disabled="disabled">
		</td>	
	</tr>
	<tr>	   
		<td colspan="2"><input type="submit" value="Crear Usuario"></input>
		<input type="button" value="Cancelar" onclick="history.back()" />
		</td>
	</tr>   
	<?php
	}
	?>
</table>
</form>
</div>
<!-- main --></div>
<!-- scene --> <?php generar_footer();?></div>
</center>
</body>
</html>
